var showGoodName = false;
var ctx;

function setFYBannerSize(size){
	this.size = size;
}
function setDaguanSize(size){
	this.fydaguanSize = size;
}
//设置初始banner图片
var currentBanner = 1;
var currentTccxIndex = 1;
var isSlider = true;
var newGoodsListLength = 0;
var index = 0;
function updateCurrentBanner() {
	if (isSlider) {
		if (currentBanner != size) {
			currentBanner = currentBanner + 1;
		} else {
			currentBanner = 1;
		}
		
		update();
	}
}

/*begin非遗大观轮播图*/
function updatedaguan(){
	for(var i = 1 ; i < fydaguanSize + 1 ; i ++){
		$("#hd" + i).hide();
	}
	$("#hd" + currentTccxIndex).show();
}

function preTccxBanner (){
	if(currentTccxIndex!=1){
  	currentTccxIndex = currentTccxIndex-1;
	}else{
		currentTccxIndex =fydaguanSize;
	}
	updatedaguan();
}
	
function nextTccxBanner (){
	if(currentTccxIndex!=fydaguanSize){
		currentTccxIndex = currentTccxIndex+1;
	}else{
		currentTccxIndex =1;
	}
	updatedaguan();
}
/*end非遗大观轮播图*/

function bannerOver(){
	isSlider=false;
	$("#bannerSwitch").show();
	$("#bannerSwitch2").show();
}

function bannerOut(){
	isSlider=true;
	$("#bannerSwitch").hide();
	$("#bannerSwitch2").hide();
}

function update(){
	for(var i = 1 ; i < size+1 ; i ++){
		$("#banner" + i).hide();
	}
	$("#banner" + currentBanner).show();
	
	for(var i = 1 ; i < size+1 ; i ++){
		$("#slider" + i).removeClass('slider-selected');
	}
	$("#slider" + currentBanner).addClass('slider-selected');
}


function categoryOver(index){
	for(var i = 0 ; i < 7 ; i ++){
		$("#firstCate" + i).removeClass('currentItem');
		$("#firstCate" + i).addClass('noCurrentItem');
		$("#dorpdownCate" + i).hide();
		
	}
	
	$("#firstCate" + index).removeClass('noCurrentItem');
	$("#firstCate" + index).addClass('currentItem');
	$("#dorpdownCate" + index).show();
	$("#fenleic").show();
}

function categoryOut(index){
	$("#firstCate" + index).removeClass('currentItem');
	$("#firstCate" + index).addClass('noCurrentItem');
	$("#dorpdownCate" + index).hide();
	$("#fenleic").hide();
}

function areaOver(index){
	for(var i = 0 ; i < 7 ; i ++){
		$("#firstArea" + i).removeClass('currentItem');
		$("#firstArea" + i).addClass('noCurrentItem');
		$("#dorpdownArea" + i).hide();
		
	}
	
	$("#firstArea" + index).removeClass('noCurrentItem');
	$("#firstArea" + index).addClass('currentItem');
	$("#dorpdownArea" + index).show();
	$("#fenleia").show();
}

function areaOut(index){
	$("#firstArea" + index).removeClass('currentItem');
	$("#firstArea" + index).addClass('noCurrentItem');
	$("#dorpdownArea" + index).hide();
	$("#fenleia").hide();
}

function areaShow(){
	$("#areaShow").show();
	$("#categoryShow").hide();
	$("#fenleia").show();
	$("#fenleic").hide();
}
function categoryShow(){
	$("#areaShow").hide();
	$("#categoryShow").show();
	$("#fenleia").hide();
	$("#fenleic").show();
}

function closeDaohang(){
	$("#feiyi").hide();
}

setTimeout(function(){
	closeDaohang();
} , 5000);

//点击具体的图片，进入三级页面
var getInfoById = function(id) {
//	$state.go("home.homeArticleDetail", {
//		id : id
//	});
};

function gotoDetail(item,type){
	window.location.href = ctx +'/intangibleNews/newsInfo?id='+ item +'&type='+type;
};

setInterval(function() {
	updateCurrentBanner();
}, 4000);

function changeBanner(index) {
	currentBanner = index;
	update();
}

function preBanner() {
	if (currentBanner != 1) {
		currentBanner = currentBanner - 1;
	} else {
		currentBanner = size;
	}
	
	update();
}

function nextBanner() {
	if (currentBanner != size) {
		currentBanner = currentBanner + 1;
	} else {
		currentBanner = 1;
	}
	
	update();
}

function getCoupon(couponId){
	$.post(ctx +"/ownerTreasure/getCoupon", {couponId:couponId}, function(data) {
		data = JSON.parse(data);
		if (data.success) {
			layer.msg(data.msg, {
				icon : 1,
				time : 1000
			// 2秒关闭（如果不配置，默认是3秒）
			}, function() {
//				window.location.href= ctx + "/main?item=" + 4;
			});
		} else {
			layer.msg(data.msg, {
				icon : 1,
				time : 2000
			// 2秒关闭（如果不配置，默认是3秒）
			});
		}
	});
}




